import {Injectable} from '@angular/core';
import {environment} from '../../environments/environment';

interface HttpInterceptorsConfig {
    gatewayServer: {
        enable: boolean,
        forward: boolean
    }
}

@Injectable()

export class ConfigService {

    imgHostname: string;
    shareHostname: string;
    hostname: string;

    constructor() {
        if (environment.production) {
            this.productionConfig();
        } else {
            this.defaultDevelopmentConfig();
        }
    }

    private defaultDevelopmentConfig() {
        this.hostname = 'http://39.106.3.39:80/api/v1';
        this.imgHostname = 'http://39.106.3.39:80/api/v1';
        this.shareHostname = '';
    }

    private productionConfig() {
        this.hostname = 'http://39.106.3.39:80/api/v1';
        this.imgHostname = 'http://39.106.3.39:80/api/v1';
        this.shareHostname = '';
    }

    public fetchFromIconfontConfig() {
        return {scriptUrl: '//at.alicdn.com/t/font_1510530_wpgqg5j36ag.js'};
    }

    public httpInterceptorsConfig(): HttpInterceptorsConfig {
        return {
            gatewayServer: {
                enable: false,
                forward: false // 转发处理方式 true 为'http://47.92.200.205:8080/api-m/layerLabel'  false为'http://47.92.200.205:8091/layerLabel'
            }
        }
    }
}
